package com.alogic.html.xscript;

import org.apache.commons.lang3.StringUtils;

import com.alogic.html.xscript.HTML.HTMLElement;
import com.alogic.xscript.ExecuteWatcher;
import com.alogic.xscript.Logiclet;
import com.alogic.xscript.LogicletContext;
import com.alogic.xscript.doc.XsObject;
import com.anysoft.util.Properties;
import com.anysoft.util.PropertiesConstants;


/**
 * @author CongZihan
 * 
 * @since 1.6.12.27 [20190327 duanyy]
 */
public class HTMLRaw extends HTMLElement {
    protected String $text = "";

    public HTMLRaw(String tag, Logiclet p) {
        super(tag, p);
    }

    @Override
    public void configure(Properties p) {
        super.configure(p);
        
        $text = PropertiesConstants.getRaw(p, "text", "");
    }

	@Override
	protected void onExecute(StringBuffer content, XsObject root, XsObject current, LogicletContext ctx,
			ExecuteWatcher watcher) {
		String text = PropertiesConstants.transform(ctx, $text, "");

		if (StringUtils.isNotEmpty(text)) {
			content.append(text);
		} else {
			super.onExecute(root, current, ctx, watcher);
		}
	}
}
